package com.zhcd.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zhcd.sys.pojo.Manage;
import com.zhcd.sys.mapper.ManageMapper;
import com.zhcd.sys.service.ManageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feifei
 * @since 2021-11-29
 */
@Service
public class ManageServiceImpl extends ServiceImpl<ManageMapper, Manage> implements ManageService {
    @Autowired
    private ManageMapper manageMapper;

    //登录
    @Override
    public Manage login(String username, String password) {
        QueryWrapper objectWrapper = new QueryWrapper<>();
        objectWrapper.eq("Loginname",username);
        objectWrapper.eq("LoginPwd",password);
        return manageMapper.selectOne(objectWrapper);
    }

    @Override
    public int upd_loginTime(Manage manage,Date date) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.set("Logindate",date);
        return manageMapper.update(null,updateWrapper);
    }

    //注册
    @Override
    public int register(Manage manage) {
        return manageMapper.insert(manage);
    }

    //查询全部用户
    @Override
    public List<Manage> getAll_Manage() {
        return manageMapper.selectList(null);
    }

    //id查询单个用户
    @Override
    public Manage getOne_Manage(int id) {
        return manageMapper.selectById(id);
    }
}
